package com.jwell.panprovider.model

import com.jwell.driverapp.tools.BaseSubscriber
import com.jwell.panprovider.application.App
import com.jwell.panprovider.contract.TransportPlaneInfoContract
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers

/**
 * Created by 76577 on 2018/4/24.
 * 供应详情-计划信息
 */
class TransportPlaneInfoModel : TransportPlaneInfoContract.Model, BaseModel() {
    override fun getData(id: Int, baseSubscriber: BaseSubscriber) {
        if (App.DEBUG) println("供应详情-获取计划信息" + id)
        val map = mutableMapOf("id" to id)
        getApiStore().supplierGetFuelPlanById(map)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(baseSubscriber)
    }

    override fun appUpdateEstimate(fuelPlanId: Int, estimateCarCount: Int, baseSubscriber: BaseSubscriber) {
        val map = mutableMapOf("fuelPlanId" to fuelPlanId, "estimateCarCount" to estimateCarCount)
        if (App.DEBUG) println("修改预登记车数" + map.toString())
        getApiStore().appUpdateEstimate(map)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(baseSubscriber)
    }
}